Use case: SMARTCARD RX DMA process ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
#define DATA_TO_RECEIVE_SIZE 255
SMARTCARD_HandleTypeDef hsmartcard;
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
/* Ensure that all required peripherals
(USART, GPIO,NVIC,DMA etc.) are configured properly
/*
...
*/
/* Smartcard register Receive complete user callback */
HAL_SMARTCARD_RegisterCallback(&hsmartcard, HAL_SMARTCARD_RX_CB_ID,
Smartcard_RxCpltCallback);
/* Start a Smartcard Process in dma mode */
HAL_SMARTCARD_Receive_DMA(&hsmartcard, aRxBuffer,
DATA_TO_RECEIVE_SIZE)
|
#define DATA_TO_RECEIVE_SIZE 255
hal_smartcard_handle_t hsmartcard;
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
/* Ensure that all required peripherals
(USART, GPIO,NVIC,DMA etc.) are configured properly
/*
...
*/
/* Smartcard register Receive complete user callback */
HAL_SMARTCARD_RegisterRxCpltCallback(&hsmartcard, Smartcard_RxCpltCallback);
/* Start a Smartcard Process in dma mode */
HAL_SMARTCARD_Receive_DMA(&hsmartcard, aRxBuffer,
DATA_TO_RECEIVE_SIZE)
|
Key changes ¶
HAL2 uses a different DMA start API for peripheral transfers (HAL_DMA_StartPeriphXfer_IT_Opt).
HAL2 provides a dedicated receive-complete callback registration API (HAL_SMARTCARD_RegisterRxCpltCallback).

